FROM hub.rys.cn/base/maven:3.6.1-alpine as BUILD

ARG module_path

WORKDIR /opt/app

COPY . /opt/app

# build module
RUN mvn install -pl ${module_path} -am -amd

FROM hub.rys.cn/base/openjdk:8-alpine

# --build-arg
ARG app_name
ARG app_version
ARG app_port
ARG module_path
ARG jar_name
ARG cfg_ext

# env
ENV APP_ENV=dev \
    APP_NAME=${app_name} \
    APP_VERSION=${app_version} \
    CFG_EXT=${cfg_ext} \
    JAVA_OPTS="-Xmx1024m"

# jar
COPY --from=BUILD /opt/app/${module_path}/target/${jar_name} /opt/app/${app_name}.jar

# port
EXPOSE ${app_port}

# volumes
VOLUME ["/opt/app/logs"]

WORKDIR /opt/app
